package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HttpClient;
import com.ruoyi.system.service.IHttpClientService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * HTTP客户端参数Controller
 * 
 * @author ZYT
 * @date 2020-08-28
 */
@RestController
@RequestMapping("/system/HttpClient")
public class HttpClientController extends BaseController
{
    @Autowired
    private IHttpClientService httpClientService;

    /**
     * 查询HTTP客户端参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:HttpClient:list')")
    @GetMapping("/list")
    public TableDataInfo list(HttpClient httpClient)
    {
        startPage();
        List<HttpClient> list = httpClientService.selectHttpClientList(httpClient);
        return getDataTable(list);
    }

    /**
     * 导出HTTP客户端参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:HttpClient:export')")
    @Log(title = "HTTP客户端参数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HttpClient httpClient)
    {
        List<HttpClient> list = httpClientService.selectHttpClientList(httpClient);
        ExcelUtil<HttpClient> util = new ExcelUtil<HttpClient>(HttpClient.class);
        return util.exportExcel(list, "HttpClient");
    }

    /**
     * 获取HTTP客户端参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:HttpClient:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(httpClientService.selectHttpClientById(id));
    }

    /**
     * 新增HTTP客户端参数
     */
    @PreAuthorize("@ss.hasPermi('system:HttpClient:add')")
    @Log(title = "HTTP客户端参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HttpClient httpClient)
    {
        return toAjax(httpClientService.insertHttpClient(httpClient));
    }

    /**
     * 修改HTTP客户端参数
     */
    @PreAuthorize("@ss.hasPermi('system:HttpClient:edit')")
    @Log(title = "HTTP客户端参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HttpClient httpClient)
    {
        return toAjax(httpClientService.updateHttpClient(httpClient));
    }

    /**
     * 删除HTTP客户端参数
     */
    @PreAuthorize("@ss.hasPermi('system:HttpClient:remove')")
    @Log(title = "HTTP客户端参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(httpClientService.deleteHttpClientByIds(ids));
    }
}
